﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CXJ.Interface;

namespace CXJ.Libiary.Cache
{
    public class WebCache : ICache
    {
        public object Get(string strkey)
        {
            if (System.Web.HttpRuntime.Cache[strkey] != null)
            {
                return System.Web.HttpRuntime.Cache[strkey];
            }
            else
            {
                return null;
            }
        }

        public void Add(string strkey, object objvalue)
        {
            System.Web.HttpRuntime.Cache.Add(strkey, objvalue, null, System.Web.Caching.Cache.NoAbsoluteExpiration, System.Web.Caching.Cache.NoSlidingExpiration, System.Web.Caching.CacheItemPriority.Default, null);
        }

        public void Remove(string strkey)
        {
            System.Web.HttpRuntime.Cache.Remove(strkey);
        }

        public bool Contains(string strkey)
        {
            object objtmp = this.Get(strkey);
            if (objtmp == null)
            {
                return false;
            }
            else
            {
                return true;
            }
        }

        public int Count
        {
            get { return System.Web.HttpRuntime.Cache.Count; }
        }

    }
}
